//
//  STUserStoryFeedViewController.swift
//  Story
//
//  Created by 汤泽川 on 2019/5/10.
//  Copyright © 2019 汤泽川. All rights reserved.
//

import UIKit

class STUserStoryFeedViewController: UIViewController , STFeedListViewDelegate{

    
    let storyManager : STStoryServiceManager
    
    init(storyManager : STStoryServiceManager) {
        self.storyManager = storyManager
        super.init(nibName: nil, bundle: nil)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .white
        let feedListView = STFeedListView(serviceManager: storyManager)
        self.view.addSubview(feedListView)
        feedListView.listViewDelegate = self
        feedListView.snp.makeConstraints({ (make) in
            make.top.equalToSuperview()
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-self.view.safeAreaInsets.bottom)
        })
        feedListView.triggerRefreshing()
    }

    func didClickCell(model: STStoryInfo) {
        let readVC = STReadStoryViewController(model: model)
        readVC.title = "Story"
        self.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(readVC, animated: true)
        self.hidesBottomBarWhenPushed = false
    }
    
}
